<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>登录</title>
<link rel="stylesheet"  href="/css/auth.css" />
<link rel="stylesheet"  href="/css/bg.css" />
 <script type="text/javascript" src="/js/jquery-3.3.1.min.js">
 </script>
</head>


<body onload="getCookie();choseRole()">

<div class="lowin">
    <div class="lowin-brand">
        <img src="/img/logo.png" />
    </div>
    <div class="lowin-wrapper">
        <div class="lowin-box lowin-login">
            <div class="lowin-box-inner">
                <form>
                    <p>CGB2008_hospital</p>

                   <div class="lowin-group">
                   
                       <input type="phone" autocomplete="phone" name="registerPhone" id="registerPhone"
                              placeholder="Phone"
                              class="lowin-input">
                   </div>
                   <div class="lowin-group">
                   
                       <input type="password" name="registerPassword" autocomplete="current-password"
                              id="registerPassword" placeholder="Password" class="lowin-input">
                   </div>
                    <div class="lowin-group">
                        <input type="checkbox" id="checkbox"/>
                        <label>记住密码</label>
                    </div>

                    <input id="loginId" type="button" style="text-align: center" class="lowin-btn login-btn"
                           value="登&emsp;录" onclick="dologin()">


                    <div class="text-foot">
                        &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
                        &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
                        &emsp;&emsp;&emsp;&emsp;<a href="zhuce1.html" class="register-link">注册</a>
                    </div>
                </form>
            </div>
        </div>



</div>

</body>
<script>
	/*初始化登录注册js*/
	Auth.init({});
	/*登录*/
	function dologin() {
       debugger
	    var user = {
	        phone: $("#registerPhone").val(),
	        password: $("#registerPassword").val(),

	    };

	    $.ajax({
	        url: "/user/dologin",
	        type: "post",
	        dataType: "text",
	        contentType: 'application/json',
	        data: JSON.stringify(user),
	        success: function (result) {

                result=JSON.parse(result);

	            if (result !== null && result.state == 1) {
	                window.location.href = "/hp/hisUser/main"
	            } else {

	                alert(result.message)
	            }

	        }
	    });

	    /**记住密码**/
	    setCookie();
	}


	/*记住密码，cookie相关*/
	function setCookie() {
	    var checked = $("#checkbox").prop("checked");
	
	    if (checked) {
	        var loginCode = $("#LoginEmail").val();
	        var pwd = $("#LoginPassword").val();
	        var flag = true;
	
	        $.cookie("login_code", loginCode);
	        $.cookie("pwd", $.base64.encode(pwd), {expires: 7});
	
	        $.cookie("flag", flag)
	
	    } else {
	        $.cookie("flag", false);
	    }
	}
	
	/*填充登录信息*/
	function getCookie() {
	    var loginCode = $.cookie("login_code");
	    var pwd = $.cookie("pwd");
	
	    var flag = $.cookie("flag");
	
	    $("#LoginEmail").val(loginCode);
	
	    if (loginCode !== undefined && flag === "true") {
	        $("#checkbox").prop("checked", true);
	        $("#LoginPassword").val($.base64.decode(pwd));
	
	    } else {
	        $("#checkbox").prop("checked", false);
	        $("#LoginPassword").val();
	    }
	
	}
</script>
</html>